FROM node:12.15.0-alpine3.11
MAINTAINER      zeze<zezecn@163.com>
ENV TZ          "Asia/Shanghai"
ENV VERSION 	1.8.3
ENV HOME        "/home"
ENV PORT        3000
ENV ADMIN_EMAIL "zezecn@163.com"
ENV DB_SERVER 	"mongo"
ENV DB_NAME 	"yapi"
ENV DB_PORT 	27017
ENV VENDORS 	${HOME}/vendors
ENV GIT_URL     https://gitee.com/mirrors/YApi.git

WORKDIR ${HOME}/

COPY entrypoint.sh /bin
COPY config.json ${HOME}
COPY wait-for-it.sh /

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \
    apk add --no-cache bash git python make openssl gcc && \
    echo ${GIT_URL} && \
	git clone ${GIT_URL} vendors && \
	cd vendors && \
	git fetch origin  v${VERSION}:v${VERSION} && \
	git checkout v${VERSION} && \
	npm config set registry https://registry.npm.taobao.org && \
	npm install -g node-gyp yapi-cli && \
	npm install --production && \
 	chmod +x /bin/entrypoint.sh && \
 	chmod +x /wait-for-it.sh

EXPOSE ${PORT}
ENTRYPOINT ["entrypoint.sh"]